package com.personnel_management.controller;

import com.personnel_management.pojo.Staff;
import com.personnel_management.pojo.StaffVo;
import com.personnel_management.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("staff")
public class StaffController {
   @Autowired
   private StaffService staffService;

    @CrossOrigin("*")
    @RequestMapping("add")
    @ResponseBody
    //添加员工
    public Integer addStaff(Staff staff) {
        return staffService.addStaff(staff);
    }

    @CrossOrigin("*")
    @RequestMapping("delete")
    @ResponseBody
    //删除员工(通过员工id)
    public Integer deleteStaff(Integer id) {
        return staffService.deleteStaff(id);
    }

    @CrossOrigin("*")
    @RequestMapping("set")
    @ResponseBody
    //修改员工(修改姓名、电话、性别、生日、毕业院校)
    public Integer setStaff(Staff staff) {
        return staffService.setStaff(staff);
    }


    //查询所有员工(多表查询) 显示出员工表的所有信息，部门表的名称、城市，职务表的职务名称、工资
    @CrossOrigin("*")
    @RequestMapping("findAll")
    @ResponseBody
    public List<StaffVo> findAllStaffs(){
        return staffService.selectAllStaffs();
    }

    @CrossOrigin("*")
    @RequestMapping("find")
    @ResponseBody
    //查询员工(按照姓名、手机号、毕业院校、部门名称、职位、性别)
    public List<StaffVo> selectStaffs(StaffVo staff) {
        return staffService.selectStaffs(staff);
    }

}
